<?php
class Proveedor extends AppModel {

	var $name = 'Proveedor';
	var $useTable = 'proveedores';
	var $displayField = 'nombre';
	var $validate = array(
		'id' => VALID_NOT_EMPTY,
		'nombre' => VALID_NOT_EMPTY,
		'pais' => VALID_NOT_EMPTY,
		'estado' => VALID_NOT_EMPTY,
		'ciudad' => VALID_NOT_EMPTY,
		'colonia' => VALID_NOT_EMPTY,
		'calle' => VALID_NOT_EMPTY,
		'num' => VALID_NOT_EMPTY,
		'cp' => VALID_NOT_EMPTY,
	);

	var $hasMany = array(
		'Vehiculo' => array('className' => 'Vehiculo',
							'foreignKey' => 'proveedor_id',
							'conditions' => '',
							'fields' => '',
							'order' => '',
							'limit' => '',
							'offset' => '',
							'dependent' => '',
							'exclusive' => '',
							'finderQuery' => '',
							'counterQuery' => ''),
	
		'Poliza' => array('className' => 'Poliza',
							'foreignKey' => 'proveedor_id',
							'conditions' => '',
							'fields' => '',
							'order' => '',
							'limit' => '',
							'offset' => '',
							'dependent' => 'true',
							'exclusive' => '',
							'finderQuery' => '',
							'counterQuery' => ''),
	);
	
	function buscar($palabraClave, $campoTabla, $tipo=""){
		$resultado = $this->query("SELECT * FROM proveedores WHERE $campoTabla = '$palabraClave' AND tipo='$tipo'");		
		return $resultado;		
	}	
}
?>
